<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="/Public/css/global.css" />
    <script src="/Public/js/jquery-1.10.2.min.js"></script>
    <script src="/Public/js/time.js"></script>
    <script src="/Public/js/jquery.min.js"></script>
    <script src="/Public/js/amazeui.min.js"></script>
    <script>
        function code()
        {
            var tel = document.getElementById("txt_UserName").value;
            var verify =  document.getElementById("txt_UserName1").value;
            var password = document.getElementById("txtpwd").value;
            var pwdTwo = document.getElementById("txt_PwdTwo").value;
            if(tel=="")
            {
                alert("手机号不能为空！");
                document.getElementById("txt_UserName").focus();
                return false;
            }else if(!(/^1[34578]\d{9}$/.test(tel)))
            {
                alert("请输入有效的手机号！");
                document.getElementById("txt_UserName").focus();
                return false;
            }else if(verify=="")
            {
                alert("手机验证码不能为空！");
                document.getElementById("txt_UserName1").focus();
                return false;
            }else if(password.length<6 ||password.length>16)
            {
                alert('请输入6~16个字符！');
                document.getElementById("txt_Pwd").focus();
                return false;
            }else if(pwdTwo.length<6 ||pwdTwo.length>16)
            {
                alert('请输入6~16个字符！');
                document.getElementById("txt_PwdTwo").focus();
                return false;
            }
            else if(pwdTwo!==password)
            {
                alert('两次密码不一致！');
                document.getElementById("txt_PwdTwo").focus();
                return false;
            }
        }

        //单击时执行
        function verify() {
            var tel = document.getElementById("txt_UserName").value;
            if(tel=="")
            {
                alert("手机号不能为空！");
                document.getElementById("txt_UserName").focus();
                return false;
            }else if(!(/^1[34578]\d{9}$/.test(tel)))
            {
                alert("请输入有效的手机号！");
                document.getElementById("txt_UserName").focus();
                return false;
            }
            //验证码倒计时
            var InterValObj; //timer变量，控制时间
            var count = 60; //间隔函数，1秒执行
            var curCount;//当前剩余秒数
            var tel = document.getElementById("txt_UserName").value;
            $.ajax({
                url: "/index.php/Home/login/verify",
                type: "post",
                data: {'tel': tel},
                datatype: "json",
                success: function (msg) {
                    alert(msg);
                },
            });


            curCount = count;
            // 设置button效果，开始计时
            document.getElementById("verify").setAttribute("onclick", "");//设置按钮为禁用状态
            document.getElementById("verify").text = "请在" + curCount + "秒后再次获取";//更改按钮文字
            InterValObj = window.setInterval(SetRemainTime, 1000); // 启动计时器
            //timer处理函数

            function SetRemainTime() {
                if (curCount == 0) {
                    window.clearInterval(InterValObj);// 停止计时器
                    document.getElementById("verify").setAttribute("onclick","verify()");//移除禁用状态改为可用
                    document.getElementById("verify").text = "重新发送验证码";
                    $("#verify").disable = "";

                } else {
                    curCount--;
                    document.getElementById("verify").text = "请在" + curCount + "秒后再次获取";
                }
            }
        }

        $(function() {
            //手机号是否否存在
            $("#txt_UserName").blur(function () {
                var tel = document.getElementById("txt_UserName").value;
                $.ajax({
                    type: "post",
                    url: "/index.php/Home/login/checkmobile",
                    data: {'tel': tel},
                    datatype: "json",
                    success: function (msg) {
                        if (msg == 1) {
                            alert("手机号不存在！");
                            document.getElementById("txt_UserName").focus();
                        }
                    }
                });
            });
        });

    </script>
</head>
<body style="background:#fff;">
<div>
    <form id="formRegister" method="post" action="/index.php/Home/login/resetcode">
        <link href="/Public/css/register.css" rel="stylesheet" type="text/css" />
        <header id="title">
            <div class="back"><a  href="javascript:void(0)" onclick="javascript:history.go(-1);return false;" ></a>  </div>
            重置密码 </header>
        <div style="height:2.8em;"></div>
        <section id="register">
            <div> <span> <img src="/Public/images/icon_phone.png" width="24" height="24" alt="手机图标"></span>
                <input

                        id="txt_UserName" name="txt_UserName" type="text" placeholder="手机号码">
            </div>

            <div> <span> <img src="/Public/images/icon_email.png" width="24" height="24" alt="手机验证码"></span>
                <input

                        id="txt_UserName1" name="txt_UserName1" type="text" placeholder="手机验证码"><a onclick="verify()" id="verify" class="fscode">获取验证码</a><!--<a href="#" class="fasong">(60)重新发送</a>-->
            </div>
            <div> <span> <img src="/Public/images/icon_password.png" width="24" height="24" alt="密码图标"> </span>
                <input id="txtpwd" name="txtpwd" type="password" placeholder="请输入重置密码（6～16个字符）">
            </div>
            <div> <span> <img src="/Public/images/icon_password.png" width="24" height="24" alt="密码图标"></span>
                <input

                        id="txt_PwdTwo"  name="txt_PwdTwo" type="password" placeholder="再次输入重置密码（6～16个字符）">
            </div>

            <input type="submit" id="asubmit" onclick="return code()" class="btn" value="提交">
        </section>
    </form>
</div>
</body>
</html>
